import http from "@/common/http";
import flashPromotion from './mock/flashPromotion.json'
import {FlashPromotion, HomeAdvertise, HomeBrand, HomeNewProduct} from "@/common/interfaces/sms";
import advertiseResponse from "@/apis/mock/adverties.json";
import roleListResponse from "@/apis/mock/roleList.json";
import HomeNewProductJson from "@/apis/mock/HomeNewProduct.json";

export async function queryHomeNewProduct(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(HomeNewProductJson)
  }
  return http('/api/sms/homenewproduct/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeHomeNewProduct(params: { ids: number[] }) {
  return http('/api/sms/homenewproduct/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addHomeNewProduct(params: HomeNewProduct) {
  return http('/api/sms/homenewproduct/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateHomeNewProduct(params: HomeNewProduct) {
  return http('/api/sms/homenewproduct/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function queryHomeBrand(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(roleListResponse)
  }
  return http('/api/sms/homebrand/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeHomeBrand(params: { ids: number[] }) {
  return http('/api/sms/homebrand/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addHomeBrand(params: HomeBrand) {
  return http('/api/sms/homebrand/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateHomeBrand(params: HomeBrand) {
  return http('/api/sms/homebrand/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function queryFlashPromotion(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(flashPromotion)
  }
  return http({
    url: '/api/sms/flashpromotion/list',
    method: 'GET',
    params
  });
}

export async function removeFlashPromotion(params: { ids: number[] }) {
  return http('/api/sms/flashpromotion/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addFlashPromotion(params: FlashPromotion) {
  return http('/api/sms/flashpromotion/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateFlashPromotion(params: FlashPromotion) {
  return http('/api/sms/flashpromotion/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function queryHomeAdvertise(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(advertiseResponse)
  }
  return http('/api/sms/homeadvertise/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeHomeAdvertise(params: { ids: number[] }) {
  return http('/api/sms/homeadvertise/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addHomeAdvertise(params: HomeAdvertise) {
  return http('/api/sms/homeadvertise/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateHomeAdvertise(params: HomeAdvertise) {
  return http('/api/sms/homeadvertise/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
